<template>
  <div>
 <h3>国内网站粉丝数量:{{fans|fansFilter('国内')}}</h3>
 <h3>国外网站粉丝数量:{{fans|fansFilter('国外')}}</h3>
 <h3>时间：{{date|formatDate('-')}}</h3>
 <h3>时间：{{date|formatDate('/')}}</h3>
  </div>
</template>

<script>
export default {
  data () {
    return {
      fans: 1876986,
      date: 1636450540055
    }
  },

  created () {

  },

  methods: {

  },
  filters: {
    fansFilter (val, adress) {
      if (adress === '国内') {
        return val / 10000 + '万'
      }
      return val / 1000 + '千'
    },
    formatDate (val, str) {
      const date = new Date(val)
      const y = date.getFullYear()
      const m = (date.getMonth() + 1).toString().padStart(2, '0')
      const d = date.getDate().toString().padStart(2, '0')
      return `${y}${str}${m}${str}${d}`
    }

  }
}
</script>
